<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	$(function() {
		$.ajaxSetup({
			  async: false
		 });
		
		parent.$.messager.progress('close');
		$('#form').form({
			url : '/buildingType/add',
			onSubmit : function() {
				parent.$.messager.progress({
					title : '提示',
					text : '数据处理中，请稍后....'
				});
				var isValid = $(this).form('validate');
				if (!isValid) {
					parent.$.messager.progress('close');
				}
				return isValid;
			},
			success : function(result) {
				parent.$.messager.progress('close');
				try{
					result = $.parseJSON(result);
					if (result.success) {
						parent.$.modalDialog.openner_datagrid.datagrid('reload');
						parent.$.modalDialog.handler.dialog('close');
					} else{
						parent.$.messager.alert("提示",result.msg, 'info');
					}
				} catch(e){
						alert(e);
					
						parent.$.messager.alert("提示",result, 'info');
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="overflow: hidden;">
		<form id="form" method="post">
			<input name="id" type="hidden" class="span2" value="${fee.id }" readonly="readonly"/>
			<table class="table table-hover table-condensed">
				<c:choose>
				<c:when test="${isAdmin}">
					<tr>
						<th>当前小区</th>
						<td>
							<select id="residenceId"  name="residenceId"  type="text" placeholder="小区名字"  class="easyui-combobox"  data-options="required:true,width:340,
											onSelect : function(a){
												$('#residenceName').val(a.text);
											},
											onLoadSuccess : function(){
												try{
													$('#residenceName').val($('#residenceId').combobox('getText'));
												} catch(e){alert(e)}											
											},
											icons:[{
											iconCls:'icon-clear',
											handler: function(e){
												$(e.data.target).combobox('setValue','');
											}
										}]" >
									<c:forEach items="${residentces }" var="r">
											<option value="${r.id }">${r.name}</option>
									</c:forEach>
							</select>
							<input id="residenceName"  type="hidden"  name="residenceName" type="" class="span2" value="" readonly="readonly"/>
						</td>
					</tr>
				</c:when>
				<c:otherwise>
				<tr>
					<th>当前小区</th>
					<td>
					<input name="residenceId" type="hidden" class="span2" value="${residence.id }" readonly="readonly"/>
					<input name="residenceName" type="text" class="span2" value="${residence.name  }" readonly="readonly"/>
					
					</td>
				</tr>
				</c:otherwise>
			</c:choose>
				<tr>
					<th>类型名称</th>
					<td><input name="name" type="text" placeholder="类型名称"   style="width:340px"class="easyui-validatebox span2" data-options="required:true" value="${fee.name }" ></td>
				</tr>
				<tr>
					<th> 基础费用（元/月/平米）</th>
					<td><input name="showBaseFee" type="text" placeholder="基础费用（元/月/平米）"   style="width:340px" class="easyui-numberbox" data-options="precision:2,required:true" value="${fee.showBaseFee }" ></td>
				</tr>
				<tr>
					<th> 其他费用（元/月）</th>
					<td><input name="showOtherFee" type="text" placeholder="其他费用（元/月）"    style="width:340px"class="easyui-numberbox" data-options="precision:2,required:true" value="${fee.showOtherFee }"></td>
				</tr>
				<tr>
					<th>排序</th>
					<td>
					<input class="easyui-slider"  name="sortWeight" style="width:330px" data-options="min:1,max:100,showTip:true">
					</td>
				</tr>
				<tr>
					<th> 费用说明</th>
					<td>
						<textarea name="remark"   style="width:340px"  data-options="required:true"></textarea>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>